<template>
  <el-select
    v-model="val"
    :disabled="disabled"
    :filterable="true"
    :default-first-option="true"
    allow-create
    placeholder="请选择或输入项目"
    clearable
    @change="$emit('change',$event)"
  >
    <el-option v-for="item in tree" :key="item.id" :label="item.name" :value="item.id" />
  </el-select>
</template>
<script>
// import name from "./name";
export default {
  // components: { name},
  props: {
    disabled: { default: false },
    value: { default: false },
    list: { default: false }
  },
  watch: {
    value(a) {
      this.val = a;
    }
  },
  data() {
    return {
      tree: [],
      val: []
    };
  },
  // computed() {return{}},
  created() {
    this.setTree();
  },
  methods: {
    setTree() {
      if (!this.list) this.list = this.$gd.process;
      this.tree = this.list.filter(a => {
        return a.pid;
      });
      if (this.value) {
        this.val = this.value;
      }
    }
  }
};
</script>

<style lang="less" scoped>
</style>
